<template>
  <div class="edit_container">
    <div class="btn_box">
      <el-button @click.stop="goBack">返回</el-button>
    </div>
    <FacialNerve ref="facialNerve" form-type="view" :patient-info="patientInfo" :assess-info="assessInfo" :doctor-type="doctorType" />
  </div>
</template>

<script>
import FacialNerve from '../../assessSys/components/facialNerve.vue'
import { nerveDetail } from '@/api/treatment/treatment.js'
import moment from 'moment'

export default {
  name: 'FacialNerveView',
  components: { FacialNerve },
  data() {
    return {
      assessId: 0,
      type: 0,
      source: 1,
      patientInfo: {},
      assessInfo: {}
    }
  },
  computed: {
    doctorType() {
      const sourceMap = {
        1: 'hospital',
        2: 'outpatient',
        3: 'therapists'
      }
      return sourceMap[this.source]
    }
  },
  mounted() {
    this.type = this.$route.query.type || 0
    this.source = this.$route.query.source
    this.assessId = this.$route.query.id
    this.getAssessInfo()
  },
  methods: {
    getAssessInfo(assessId) {
      // 执行获取治疗详情
      nerveDetail({
        type: this.type,
        evaluateSource: this.source,
        relationId: this.assessId
      }).then(res => {
        this.patientInfo = {
          ...res.content,
          genderName: res.content.gender === 0 ? '女' : '男'
        }
        if (res.content.evaluateTime) {
          res.content.evaluateTime = moment(res.content.evaluateTime).format('YYYY-MM-DD HH:mm:ss')
        }
        this.assessInfo = {
          ...this.assessInfo,
          ...res.content
        }
      })
    },
    goBack() {
      this.$store.dispatch('tagsView/delView', this.$route)
      this.$router.back()
    }
  }
}
</script>

<style lang="scss" scoped>
@import url('./style.scss');
</style>
